package com.imesne.assistant.common.exception;


import com.imesne.assistant.common.enums.IEnum;

/**
 * 自定义异常类
 * <p/>
 * Created by liyd on 6/27/14.
 */
public class ImesneException extends RuntimeException {

    private static final long serialVersionUID = 3731036212843506314L;

    /**
     * Exception code
     */
    protected String resultCode = "UN_KNOWN_EXCEPTION";

    /**
     * Exception message
     */
    protected String resultMsg = "未知异常";

    /**
     * Instantiates a new ImesneException.
     *
     * @param e the e
     */
    public ImesneException(IEnum e) {
        super(e.getDesc());
        this.resultCode = e.getCode();
        this.resultMsg = e.getDesc();
    }

    public ImesneException(String message, Throwable e) {
        super(message, e);
        this.resultMsg = message;
    }

    public ImesneException(IEnum msgEnum, Throwable e) {
        super(msgEnum.getDesc(), e);
        this.resultCode = msgEnum.getCode();
        this.resultMsg = msgEnum.getDesc();
    }

    /**
     * Instantiates a new ImesneException.
     *
     * @param e the e
     */
    public ImesneException(Throwable e) {
        super(e);
        this.resultMsg = e.getMessage();
    }

    /**
     * Constructor
     *
     * @param message the message
     */
    public ImesneException(String message) {
        super(message);
        this.resultMsg = message;
    }

    /**
     * Constructor
     *
     * @param code    the code
     * @param message the message
     */
    public ImesneException(String code, String message) {
        super(message);
        this.resultCode = code;
        this.resultMsg = message;
    }

    public String getResultCode() {
        return resultCode;
    }

    public String getResultMsg() {
        return resultMsg;
    }

}
